﻿<UserControl x:Class="SoftTeach.View.Wochenpläne.MetroTerminplaneinträgeDetailView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:wochenpläneView="clr-namespace:SoftTeach.View.Wochenpläne"
             xmlns:wochenpläne="clr-namespace:SoftTeach.ViewModel.Wochenpläne"
             xmlns:local="clr-namespace:SoftTeach.Resources.Controls"
             mc:Ignorable="d" 
             d:DesignHeight="100" d:DesignWidth="200" 
             GotMouseCapture="UIElement_OnGotMouseCapture">
  <UserControl.Resources>
    <DataTemplate DataType="{x:Type wochenpläne:TerminplanEintrag}" x:Key="MetroTerminplanEintragTemplate">
      <wochenpläneView:MetroTerminplaneintragDetailView />
    </DataTemplate>
    <Style x:Key="UnselectableListboxStyle">
      <Style.Resources>
        <!-- Background of selected item when focussed -->
        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
        <!-- Background of selected item when not focussed -->
        <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
        <!-- Background of selected item when inactive -->
        <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="Transparent" />

      </Style.Resources>
    </Style>

  </UserControl.Resources>
  <ListBox ItemsSource="{Binding Path=TerminplanEinträge}" x:Name="SurroundBorder"
           Style="{StaticResource UnselectableListboxStyle}"
           MouseEnter="SurroundBorderMouseEnter"
           PreviewMouseLeftButtonDown="SurroundBorderMouseLeftButtonDown"
           ItemTemplate="{StaticResource MetroTerminplanEintragTemplate}" 
           BorderThickness="0"
           Background="Transparent" BorderBrush="Transparent" 
           HorizontalContentAlignment="Stretch"
           VerticalContentAlignment="Stretch"
           IsTextSearchEnabled="False" 
           ScrollViewer.CanContentScroll="False" 
           ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
           ScrollViewer.VerticalScrollBarVisibility="Disabled">
    <ListBox.ItemsPanel>
      <ItemsPanelTemplate>
        <Grid 
              local:GridTools.RowCount="{Binding MaxStundenAnzahl}"
              local:GridTools.ColumnCount="{Binding AnzahlEinträge}"/>
      </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <ItemsControl.ItemContainerStyle>
      <Style>
        <Setter Property="Grid.Column" Value="{Binding ColumnIndex}" />
        <Setter Property="Grid.Row" Value="{Binding RowIndex}" />
        <Setter Property="Grid.ColumnSpan" Value="{Binding ColumnSpan}" />
        <Setter Property="Grid.RowSpan" Value="{Binding RowSpan}" />
        <Setter Property="ListBoxItem.Padding" Value="0"/>
        <Setter Property="ListBoxItem.Background" Value="Transparent"/>
        <Setter Property="FrameworkElement.HorizontalAlignment"  Value="Stretch"/>
        <Setter Property="FrameworkElement.VerticalAlignment"  Value="Stretch"/>
        <Style.Triggers>
          <Trigger Property="ListBoxItem.IsSelected" Value="true">
            <Setter Property="ListBoxItem.Background" Value="Yellow"/>
          </Trigger>
          <Trigger Property="ListBoxItem.IsSelected" Value="False">
            <Setter Property="ListBoxItem.Background" Value="Transparent"/>
          </Trigger>
        </Style.Triggers>
      </Style>
    </ItemsControl.ItemContainerStyle>
  </ListBox>
</UserControl>
